package com.free.mini.core.serve.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.free.mini.core.serve.entity.UserBase;
import com.free.mini.core.serve.mapper.UserBaseMapper;
import com.free.mini.core.serve.service.IUserBaseService;

import lombok.RequiredArgsConstructor;

/**
 * 用户表 Service实现
 *
 * @author dongsufeng
 * @date 2023-08-02 17:51:14
 */
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class UserBaseServiceImpl extends ServiceImpl<UserBaseMapper, UserBase> implements IUserBaseService {

    private final UserBaseMapper userBaseMapper;

    @Override
    public IPage<UserBase> findUserBase(UserBase userBase) {
        LambdaQueryWrapper<UserBase> queryWrapper = new LambdaQueryWrapper<>();
        // TODO 设置查询条件
        Page<UserBase> page = new Page<>(0,1);
        return this.page(page, queryWrapper);
    }

    @Override
    public List<UserBase> findUserBases(UserBase userBase) {
	    LambdaQueryWrapper<UserBase> queryWrapper = new LambdaQueryWrapper<>();
		// TODO 设置查询条件
		return this.baseMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void createUserBase(UserBase userBase) {
        this.save(userBase);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateUserBase(UserBase userBase) {
        this.saveOrUpdate(userBase);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteUserBase(UserBase userBase) {
        LambdaQueryWrapper<UserBase> wrapper = new LambdaQueryWrapper<>();
	    // TODO 设置删除条件
	    this.remove(wrapper);
	}
}
